package com.zjlanyun.erp.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBHelper extends SQLiteOpenHelper {

	private static final String DATABASE_NAME = "lanyun.db";
	private static final int DATABASE_VERSION = 2; // 数据库版本号，修改数字会自动执行onUpgrade中的SQL语句，用于更新数据

	public DBHelper(Context context) {
		// CursorFactory设置为null,使用默认值
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// 客户未提交单据商品表
		db.execSQL("CREATE TABLE IF NOT EXISTS CSaleOrderAddList (_id INTEGER PRIMARY KEY AUTOINCREMENT, code VARCHAR, name VARCHAR, model VARCHAR, taxUnitPrice DECIMAL(10,2), taxAmount DECIMAL(10,2), stock DECIMAL(10,2), unit VARCHAR, quantity VARCHAR, remark VARCHAR)");
		// 产品表
		db.execSQL("CREATE TABLE IF NOT EXISTS ICInStockBillEntry (_id INTEGER PRIMARY KEY AUTOINCREMENT, FNumber VARCHAR, FName VARCHAR, FModel VARCHAR, FAuxProp1 VARCHAR, FBatchNO VARCHAR, FQty DECIMAL(10,2))");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// 执行更新操作
		// db.execSQL("ALTER TABLE OLD_COMPANY ADD COLUMN SEX char(1)");
		db.execSQL("CREATE TABLE IF NOT EXISTS ICInStockBillEntry (_id INTEGER PRIMARY KEY AUTOINCREMENT, FNumber VARCHAR, FName VARCHAR, FModel VARCHAR, FAuxProp1 VARCHAR, FBatchNO VARCHAR, FQty DECIMAL(10,2));");
	}

}
